package Operations;

import Book.book;
import Book.bookList;

import java.util.Scanner;
//定义查找增书籍操作这个类重写实现接口中的work抽象方法
public class FindOperation implements Ioperations {
    @Override
    public void work(bookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要查找的书籍");
        String name = scanner.nextLine();
        //获取当前书架书籍的总数
        int used = bookList.getUseMount();
        //用遍历的方式查询书架中是否存在输入的书名
        for (int i = 0; i < used; i++) {
            //用bookList已写的方法获取下标为i的书对象
            book book = bookList.getBooks(i);
            if (book.getName().equals(name)) {
                System.out.println("该书找到了");
                System.out.println(book);
                return;
            }
        }
        System.out.println("抱歉没找到此书籍");
    }
}

